package com.dalin.demo.service.imple;

import com.dalin.demo.dao.OaMessageMapper;
import com.dalin.demo.pojo.entity.OaMessage;
import com.dalin.demo.service.OaMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class OaMessageServiceImpl implements OaMessageService {
    @Autowired
    private OaMessageMapper oaMessageMapper;

    @Override
    public List<OaMessage> getAllOaMessages() {
        return oaMessageMapper.listOaMessages();
    }

    @Override
    public List<OaMessage> listOaMessagesByParams(Map<String, Object> params) {
        return oaMessageMapper.listOaMessagesByParams(params);
    }

    public Integer addOaMessage(OaMessage OaMessage) {
        OaMessage.setCreateDate(new Date());
        oaMessageMapper.insertOaMessage(OaMessage);
        return OaMessage.getId();
    }

    public Integer updateOaMessage(OaMessage OaMessage) {
        oaMessageMapper.updateOaMessage(OaMessage);
        return OaMessage.getId();
    }

    public Integer deleteOaMessage(int id) {
        oaMessageMapper.deleteOaMessageById(id);
        return id;
    }

    public void deleteOaMessages(List<String> ids) {
        oaMessageMapper.deleteOaMessages(ids);
       // return id;
    }

    public OaMessage getOaMessageById(int id) {
        return oaMessageMapper.getOaMessageById(id);
    }
}